const jwt = require("jsonwebtoken");

// const {
//   login
// } = require("../services/user.services")
const {
  SERCT_KEY
} = require("../app/config")
class AuthController {
  async login(req, res, next) {
    // console.log(req.body, "login")
    // const result =await login(req.body)
    // res.json({
    //   msg: name,
    //   password
    // })
    // console.log("123", req)
    console.log("login,", "login")
    const token = jwt.sign(req.user, SERCT_KEY, {
      expiresIn: 60 * 60 * 24
    })
    const {id, name} = req.user;
    res.json({
      id,
      name,
      token
    })
  }
};


module.exports = new AuthController()